﻿using System.Collections.Generic;
using UnityEngine;

namespace UFrame.ECS
{
    /// <summary>
    /// 是一个间接,负责初始化Monohavir 转换成System
    /// 需要一个初始化顺序
    /// </summary>
    public class UEntityMono : MonoBehaviour
    {
        public List<USystemMono> orderList = new List<USystemMono>();

        public void Awake()
        {
            PrepareSystem();
        }

        public void PrepareSystem(UEntity ue = null)
        {
            if (ue == null)
                ue = new UEntity();

            if (orderList.Count > 0)
            {
                ue.SetRoot(gameObject, false); //不搜索系统组件
                ue.AddSystemRang(orderList);
            }
            else
            {
                ue.SetRoot(gameObject);
            }
            ue.PrepareInit();
        }
    }
}